//
//  Stack.m
//  KLGenerateSpamCode
//
//  Created by lxm on 2023/4/24.
//  Copyright © 2023 GAEA. All rights reserved.
//

#import "Stack.h"

@implementation Stack

- (instancetype)init {
    self = [super init];
    if (self) {
        _elements = [NSMutableArray array];
    }
    return self;
}

- (void)push:(id)element {
    [self.elements addObject:element];
}

- (id)pop {
    id element = [self.elements lastObject];
    [self.elements removeLastObject];
    return element;
}

- (id)getTop {
    return [self.elements lastObject];
}

- (BOOL)isEmpty {
    return self.elements.count == 0;
}


@end
